<?php
namespace app\admin\controller;

use app\common\controller\Back;

class Score extends Back
{
    protected function initialize()
    {
        parent::initialize();
    }
    
    public function index()
    {
        $form = xfFormCreate([
            'name'         => 'adminScoreIndex',
            'action'       => xfUrl('admin/score/update'),
            'items'        => model('admin/Score','form')->items(config('score.')),
            'reset'        => '重置',
            'class_button' => 'text-left',
        ]);

        $this->assign('form',$form);

        $this->assign($this->site);

        return $this->fetch();
    }

    public function update()
    {
        $post = xfArrayFilter(input('post.'), array_keys(model('admin/Score','form')->items()));
        if(!$post){
            $this->error('参数错误');
        }

        $this->configSave('./config/score.php', $post, 'admin/score/index');
    }
}